/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author facundo
 */
@Entity
@Table(name = "caja")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Caja.findAll", query = "SELECT c FROM Caja c"),
    @NamedQuery(name = "Caja.findById", query = "SELECT c FROM Caja c WHERE c.id = :id"),
    @NamedQuery(name = "Caja.findByResponsable", query = "SELECT c FROM Caja c WHERE c.responsable = :responsable"),
    @NamedQuery(name = "Caja.findByFecha", query = "SELECT c FROM Caja c WHERE c.fecha = :fecha"),
    @NamedQuery(name = "Caja.findByResponsableFecha", query = "SELECT c FROM Caja c WHERE c.responsable = :responsable AND c.fecha = :fecha"),
    @NamedQuery(name = "Caja.findUnderFecha", query = "SELECT c FROM Caja c WHERE c.fecha >= :fecha"),
    @NamedQuery(name = "Caja.findByOperacion", query = "SELECT c FROM Caja c WHERE c.operacion = :operacion"),
    @NamedQuery(name = "Caja.findByImporte", query = "SELECT c FROM Caja c WHERE c.importe = :importe"),
    @NamedQuery(name = "Caja.findByMoneda", query = "SELECT c FROM Caja c WHERE c.moneda = :moneda")})
public class Caja implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    @Basic(optional = false)
    @Column(name = "observaciones")
    private String observaciones;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "responsable")
    private int responsable;
    @Basic(optional = false)
    @Column(name = "fecha")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @Basic(optional = false)
    @Column(name = "operacion")
    private int operacion;
    @Basic(optional = false)
    @Column(name = "importe")
    private Double importe;
    @Basic(optional = false)
    @Column(name = "moneda")
    private String moneda;

    public Caja() {
    }

    public Caja(Integer id) {
        this.id = id;
    }

    public Caja(Integer id, int responsable, Date fecha, int operacion, Double importe, String moneda) {
        this.id = id;
        this.responsable = responsable;
        this.fecha = fecha;
        this.operacion = operacion;
        this.importe = importe;
        this.moneda = moneda;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        Integer oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public int getResponsable() {
        return responsable;
    }

    public void setResponsable(int responsable) {
        int oldResponsable = this.responsable;
        this.responsable = responsable;
        changeSupport.firePropertyChange("responsable", oldResponsable, responsable);
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        Date oldFecha = this.fecha;
        this.fecha = fecha;
        changeSupport.firePropertyChange("fecha", oldFecha, fecha);
    }

    public int getOperacion() {
        return operacion;
    }

    public void setOperacion(int operacion) {
        int oldOperacion = this.operacion;
        this.operacion = operacion;
        changeSupport.firePropertyChange("operacion", oldOperacion, operacion);
    }

    public Double getImporte() {
        return importe;
    }

    public void setImporte(Double importe) {
        Double oldImporte = this.importe;
        this.importe = importe;
        changeSupport.firePropertyChange("importe", oldImporte, importe);
    }

    public String getMoneda() {
        return moneda;
    }

    public void setMoneda(String moneda) {
        String oldMoneda = this.moneda;
        this.moneda = moneda;
        changeSupport.firePropertyChange("moneda", oldMoneda, moneda);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Caja)) {
            return false;
        }
        Caja other = (Caja) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.fecha.toString()+" "+this.importe;
    }

    public String getObservaciones() {
        return observaciones;
    }

    public void setObservaciones(String observaciones) {
        String oldObservaciones = this.observaciones;
        this.observaciones = observaciones;
        changeSupport.firePropertyChange("observaciones", oldObservaciones, observaciones);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
